<%--
  Created by IntelliJ IDEA.
  User: 862982795
  Date: 2021/06/23
  Time: 17:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加联系人信息</title>
    <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"></script>
    <script>
        // Fallback to loading jQuery from a local path if the CDN is unavailable
        (window.jQuery || document.write('<script src="/scripts/jquery-1.9.0.min.js"><\/script>'));
    </script>
</head>
<body>

<div align="center">


    <form action="${pageContext.request.contextPath}/doAdd" method="get">
        <table border="1" cellspacing="0">
            <tr>
                <th colspan="2" style="font-size: 30px">添加联系人</th>
            </tr>
            <tr>
                <td>姓名(*)</td>
                <td>
                    <%--                <input type="hidden" name="status" value="0"/>--%>
                    <input type="text" class="cname" name="cname">
                </td>
            </tr>
            <tr>
                <td>手机(*)</td>
                <td><input type="text" class="mobile" name="mobile"><span></span></td>
            </tr>
            <tr>
                <td>QQ(*)</td>
                <td><input type="text" class="qq" name="qq"></td>
            </tr>

            <tr>
                <td>Email(*)</td>
                <td><input type="text" class="email" name="email"></td>
            </tr>
            <tr>
                <td>地址(*)</td>
                <td>
                    <%--                <input type="hidden" name="status" value="0"/>--%>
                    <input type="text" class="address" name="address">
                </td>
            </tr>

            <tr>
                <td colspan=" 2" align="center">
                    <button>添加</button>&nbsp;&nbsp;<input type="reset" value="重置">&nbsp;
                    <button type="button" onclick="history.back();">返回</button>
                </td>
            </tr>
        </table>
    </form>
</div>
<script type="text/javascript">
    $(function () {
        var verification = false;

        $("form").submit(function () {
            var isSub = true;
            var isFocus = false;
            $("input[type='text']").each(function () {
                if ($(this).val() === "") {
                    if (!isFocus) {
                        $(this).focus();
                        isFocus = true;
                    }
                    isSub = false;
                }
            });
            $("select").each(function () {
                if ($(this).val() === "") {
                    if (!isFocus) {
                        $(this).focus();
                        isFocus = true;
                    }
                    isSub = false;
                }
            });
            $("textarea").each(function () {
                if ($(this).val() === "") {
                    if (!isFocus) {
                        $(this).focus();
                        isFocus = true;
                    }
                    isSub = false;
                }
            });
            if (!isSub) {
                alert("此输入框不能为空!");
                return false;
            }

            // var dataFormat = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/;
            // var flag = dataFormat.test($(".maturityDate").val());
            // if (!flag) {
            //     alert("日期格式错误，请重新输入!");
            //     $(".createDate").focus();
            //     return false;
            // }

            if (verification) {
                return false;
            }
        });
    })

</script>
</body>
</html>
